<%@ page pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ page trimDirectiveWhitespaces="true" %>
<fmt:setLocale value="zh_CN"/>
<div class="cg_container">
	<!-- t改为shieldTarget，且为jQuery选择器形式,notAutoSubmit表示不自动提交 -->
    <form id="cgSearchForm" action="${ctxPathA}/system/outdatabase/tables" method="post" shieldTarget="#cg_tablesDiv" class="searchForm" notAutoSubmit>
        <div class="searchForm">
            <b>连接：</b>
            <select name="conn" class="shieldSelectRelated">
            	<option value="0">本项目库</option>
    <c:forEach var="dbset" items="${dbsets }">
    			<option value="${dbset.id }">${dbset.dbSetName }</option>
    </c:forEach>
            </select>
            <b>表名：</b><input type="text" name="tableName" id="codeGenTableName" style="width: 100px;">
            <input class="button submit" type="submit" name="doSearch" value="查询">
        </div>
    </form>
    <div id="cg_tablesDiv" class="midtabDiv "><div style="font-size: 14px; width:400px;margin-top: 50px;text-align: center;" class="tips">请先搜索表</div></div>
   </div>
<script>
/* 搜索 */
$("#codeGenTableName").keyup(function(){
	var tableE = $("#cg_tablesDiv").find("table");
	if (tableE.length > 0) {
	  	var _defaults = {
			/**前景色*/
			foreground: 'red',    
			/**背景色*/
		    background: 'yellow'    
		};
		var $search = $(this);
	    var searchKey = $.trim($search.val());
	    if (searchKey) {
	    	var options = $.extend(true, _defaults, getSettings($search));
	    	tableE.find("tr.datatr").hide();
	    	tableE.find("tr.datatr").filter(function() {
	    		if ($(this).text().toLowerCase().indexOf(searchKey.toLowerCase())!=-1) {
	    			ShieldJS.debug(searchKey);
	    			var reg = new RegExp("("+searchKey+")", "gi"); //全局并忽略大小写
	    			$(this).find("td.datatd").each(function(i) {
	    				var newstr = $(this).data("html").replace(reg, '<strong style="background-color: '+options.background+';color: '+options.foreground+';">$1</strong>');
	    				$(this).html(newstr);
	                });
	    			return true;
	    		}
	    		return false; 
	    	}).show();
	    } else {
	    	tableE.find("tr.datatr").show().find("td.datatd").each(function(i) {
				$(this).html($(this).data("html"));
			});
		}
    }
});
//默认显示
$(".bnt1").click(function () {
	$(".cg_tables").click();
});
</script>
